package com.data.modules.online.cgform.util;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.data.common.system.api.ISysBaseAPI;
import com.data.common.util.SpringContextUtils;
import com.data.modules.online.cgform.entity.OnlCgformField;
import org.jeecgframework.poi.handler.impl.ExcelDataHandlerDefaultImpl;
import org.jeecgframework.poi.util.PoiPublicUtil;

public class CgFormExcelHandler extends ExcelDataHandlerDefaultImpl {

    Map<String, OnlCgformField> f222a;

    ISysBaseAPI f223b;

    String f224c;

    String f225d = "online";

    String f226e;

    public CgFormExcelHandler(List<OnlCgformField> list, String str, String str2) {
        this.f222a = getOnlCgformFieldMap(list);
        this.f224c = str;
        this.f226e = str2;
        this.f223b = (ISysBaseAPI) SpringContextUtils.getBean(ISysBaseAPI.class);
    }

    private Map<String, OnlCgformField> getOnlCgformFieldMap(List<OnlCgformField> list) {
        HashMap hashMap = new HashMap();
        for (OnlCgformField onlCgformField : list) {
            hashMap.put(onlCgformField.getDbFieldTxt(), onlCgformField);
        }
        return hashMap;
    }

    public void setMapValue(Map<String, Object> map, String originKey, Object value) {
        String a = getTable(originKey);
        if (value instanceof Double) {
            map.put(a, PoiPublicUtil.doubleToString((Double) value));
        } else if (value instanceof byte[]) {
            String a2 = CgformUtil.m236a((byte[]) ((byte[]) value), this.f224c, this.f225d, this.f226e);
            if (a2 != null) {
                map.put(a, a2);
            }
        } else {
            map.put(a, value == null ? "" : value.toString());
        }
    }

    private String getTable(String str) {
        if (this.f222a.containsKey(str)) {
            return "$mainTable$" + this.f222a.get(str).getDbFieldName();
        }
        return "$subTable$" + str;
    }
}
